// $codepro.audit.disable disallowTestAnnotation
// Test annotations should be allow so Java can regconize
// the test methods
/**
 * Require imports
 */
import static org.junit.Assert.assertEquals;
import org.junit.Test;

/**
 * TravelEventTest
 * 
 * @author Hung Lac
 * @version 1.0
 */
public class TravelEventTest {

	/**
	 * Hung Lac
	 */
	@Test
	public void testRob0() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().getGoodsArray()[0].setSold(6);
		new TravelEvent(model, view, 0);
		assertEquals("Failed rob case 0", 4,
				model.getShip().getGoodsArray()[0].getSold());
	}

	/**
	 * Hung Lac
	 */
	@Test
	public void testRob1() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().setCargo(6);
		model.getShip().getGoodsArray()[0].setSold(6);
		new TravelEvent(model, view, 0);
		assertEquals("Failed rob case 1", 4, model.getShip().getCargo());
	}

	/**
	 * Hung Lac
	 */
	@Test
	public void testRob2() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().setCargo(6);
		model.getShip().getGoodsArray()[0].setSold(6);
		new TravelEvent(model, view, 0);
		assertEquals("Failed rob case 2", "4", view.sell[0].getText());
	}

	/**
	 * Hung Lac
	 */
	@Test
	public void testRob3() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().setCargo(6);
		model.getShip().getGoodsArray()[0].setSold(6);
		new TravelEvent(model, view, 0);
		assertEquals("Failed rob case 3", "Bay Filled: 4/15",
				view.lblBaysFilled.getText());
	}

	/**
	 * Justin Cook
	 */
	@Test
	public void testFuelDepletion() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		new TravelEvent(model, view, 1);
		assertEquals("Result", 19, model.getShip().getFuel());
	}

	/**
	 * Anna Russell
	 */
	@Test
	public void testFoundRandomGood() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		int cargo = model.getShip().getCargo();
		new TravelEvent(model, view, 2);
		if (model.getShip().getCargo() > cargo) {
			cargo += 2;
		}
		assertEquals("Result", cargo, model.getShip().getCargo());
	}

	/**
	 * John Storey
	 */
	@Test
	public void testBribeCops() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		new TravelEvent(model, view, 3);
		assertEquals("Failed to bribe cops", 950, model.getPlayer()
				.getCredits());
	}

	/**
	 * Ore
	 */
	@Test
	public void testRats0() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().getGoodsArray()[0].setSold(4);
		new TravelEvent(model, view, 4);
		assertEquals("Result", 4, model.getShip().getGoodsArray()[0].getSold());
	}

	/**
	 * Ore
	 */
	@Test
	public void testRats1() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().getGoodsArray()[0].setSold(3);
		new TravelEvent(model, view, 4);
		assertEquals("Result", 3, model.getShip().getGoodsArray()[0].getSold());
	}

	/**
	 * Ore
	 */
	@Test
	public void testRat2() {
		final Model model = new Model();
		final View view = new View(model);
		view.dispose();
		model.getShip().getGoodsArray()[0].setSold(5);
		new TravelEvent(model, view, 4);
		assertEquals("Result", 3, model.getShip().getGoodsArray()[0].getSold());
	}

	/**
	 * toString
	 * 
	 * @return String
	 */
	public String toString() {
		return this.toString();
	}

}
